package de.unikoblenz.west.csxpoi.server.connector;

import java.io.PrintWriter;
import java.util.List;

import org.openrdf.model.URI;
import org.openrdf.model.ValueFactory;
import org.openrdf.query.BindingSet;
import org.openrdf.query.MalformedQueryException;
import org.openrdf.query.QueryEvaluationException;
import org.openrdf.query.QueryLanguage;
import org.openrdf.query.TupleQuery;
import org.openrdf.query.TupleQueryResult;
import org.openrdf.repository.Repository;
import org.openrdf.repository.RepositoryConnection;
import org.openrdf.repository.RepositoryException;
import org.openrdf.repository.http.HTTPRepository;
import de.unikoblenz.west.csxpoi.server.*;

/**
 * Connector to a datastore that uses Sesame API to communicate
 * 
 * @author Yassin Nachite
 *
 */
abstract class SesameConnector extends SourceConnector {

	Repository repository = null;
	RepositoryConnection connection = null;

	public SesameConnector() {
		initialize();
	}

	public SesameConnector(String serverAdress, String repositoryID) {
		if (serverAdress != "") {
			this.serverAdress = serverAdress;
			this.repositoryID = repositoryID;
		}
		initialize();
	}

	@Override
	public void initialize() {
		try {
			repository = new HTTPRepository(serverAdress, repositoryID);
			repository.initialize();

		} catch (RepositoryException e) {
			e.printStackTrace();
		}
	}

	abstract List<BindingSet> sendRequest(String rdfQuery);

}
